package my.jwds.p396;

public class MaxRotateFunction {

    public static void main(String[] args) {

        Solution obj = new Solution();
        long start = System.currentTimeMillis();
        System.out.println("运行时间:" + (System.currentTimeMillis() - start));
    }

    static class Solution {


        public int maxRotateFunction(int[] nums) {
            int sum = 0,max = 0,count = 0,len = nums.length;
            for (int i = 0; i < len; i++) {
                sum += nums[i];
                count += i * nums[i];
            }
            max = count;
            for (int i = len-1; i > 0; i--) {
                count = count - nums[i]* (len-1) + sum - nums[i];
                max = Integer.max(count,max);
            }

            return max;

        }


    }
}